package jdk.comparable;

public class DataSorter {
	public static Object[] sort(Object a[]){
		for(int i = a.length;i>0;i--){
			for(int j = 0 ;j<i-1;j++){
				java.lang.Comparable o1 = (java.lang.Comparable)a[j];
				java.lang.Comparable o2 = (java.lang.Comparable)a[j+1];
				if(o1.compareTo(o2) == 1){
					swap(a, j,j+1);
				}
			}
		}
		return a;
	}

	private static void swap(Object[] a, int x, int y) {
		Object temp = a[x];
		a[x] = a[y];
		a[y] = temp;
		
	}

	private static void swap(int[] a, int x,int y) {
		int temp = a[x];
		a[x] = a[y];
		a[y] = temp;
	}
	public static void p(Object[] a){
		for(Object c:a){
			System.out.println(c);
		}
	}

}
